Avorion Script API Documentation

Sector [Client]

This object is only available on the client.

function Sector()

Returns

A new instance of Sector

property string name
Get the name of the sector, as specified by its SectorSpecifics
property Seed seed[read-only]

function var addInertiaFieldGlow(var id)

Returns

nothing

function var addStaticHyperspaceGlow(var id)

Returns

nothing

function int callbacksRegistered(string callbackName, var functionName)

Check how many functions are registered to a callback from the current script VM.

Parameters

callbackName The name of the callback
functionName The name of the function for which to check. If nil, will count all functions that are registered to this callback.

Returns

The amount of functions registered to the callback

function var createDust(vec3 pos, float size, Color color, float lifeSpan)

Returns

nothing

function var createDustExplosion(vec3 pos, float size, Color color)

Returns

nothing

function var createExplosion(vec3 pos, float size, bool silent)

Returns

nothing

function var createGlow(vec3 pos, float size, Color color)

Returns

nothing

function GlowFX createGlowBox(Box box)

function var createGlows(vec3... positions, float size, Color color)

Returns

nothing

function GlowFX createGlowSphere(float radius, ivec2 resolution)

function var createHyperspaceEnteringGlowAnimation(Entity entity)

Returns

nothing

function var createHyperspaceJumpAnimation(Entity entity, vec3 [or nil] direction, Color [or nil] color, var intensity)

Returns

nothing

function LaserFX createLaser(vec3 from, vec3 to, Color color, float width)

function RefractionFX createRefractionBox(Box box)

function RefractionFX createRefractionSphere(float radius, ivec2 resolution)

function var createShockwave(vec3 pos, float size, float duration, vec3 color)

Returns

nothing

function var createSpark(vec3 pos, vec3 v, float size, float aliveTime, Color color, float slowDownFactor, Entity [or nil] entity, var texture)

Returns

nothing

function Entity... getAllies(int factionIndex)

Returns all allies of the given faction in the sector. Allies include ships of the same faction. Allied entities are determined as follows:
- they belong to the same faction
- they belong to factions whose relations are above 70.000
- they belong to players of the same group
- they belong to players of the same alliance
- they belong to a player and their alliance

Parameters

factionIndex The faction index of the faction whose ally ships are to be queried

Returns

Multiple values: All detected allies in the sector

function int, int getCoordinates()

function Entity... getEnemies(int factionIndex)

Returns all enemies of the given faction in the sector. Enemies are determined as ships of factions where relations are below -40.000

Parameters

factionIndex The faction index of the faction whose enemy ships are to be queried

Returns

Multiple return values: All detected enemies in the sector

function Entity... getEntities()

function Entity... getEntitiesByComponent(int component)

function Entity... getEntitiesByComponents(Type... types)

Returns all entities in the sector that have a specific set of components

Parameters

types The desired set of component types (See enum ComponentType)

Returns

Multiple return values: All matching entities in the sector

function Entity... getEntitiesByFaction(int factionIndex)

function Entity... getEntitiesByLocation(Sphere sphere)

function Entity... getEntitiesByScript(string scriptName)

function Entity... getEntitiesByScriptValue(string name, var value)

Returns all entities in the sector that have a specific value assigned to them. Values can be set with Entity:setValue(name, value) and read with Entity:getValue(name).

Parameters

name The value name to check for
value A value to check against. If this is set, only entities will be returned whose value is equal to the passed value. If this is nil, all entities will be returned that have any value with the given name assigned.

Returns

Multiple return values: All matching entities in the sector

function Entity... getEntitiesByType(int type)

function Entity getEntity(var id)

function Entity getEntityByFactionAndName(int factionIndex, string name)

function unsigned int getNumAllies(int faction)

function unsigned int getNumEnemies(int factionIndex)

function unsigned int getNumEntities()

function unsigned int getNumEntitiesByComponent(int component)

function unsigned int getNumEntitiesByComponents()

function unsigned int getNumEntitiesByFaction(int factionIndex)

function unsigned int getNumEntitiesByLocation(Sphere sphere)

function unsigned int getNumEntitiesByScript(string scriptName)

function unsigned int getNumEntitiesByType(int type)

function int... getPresentFactions()

Returns all indices of all present factions

Returns

a list of int indices of all present factions

function var getValue(string name)

function UserObject... intersectBeamRay(Ray ray, Uuid [or nil] ignoredEntity, Uuid [or nil] ignoredEntityShields)

Intersects a beam in the sector, similar to the way that weapon beams are intersected. If an entity has a shield, that shield will be part of the test. If the beam would intersect with multiple entities, then the entity with its intersection point closest to the ray origin is chosen.

Parameters

ray The ray that should be intersected
ignoredEntity A uuid that can be optionally set. If this was set, the entity with this ID will be ignored during the intersection.
ignoredEntityShields A uuid that can be optionally set. If this was set, the shields of the entity with this ID will be ignored during the intersection.

Returns

The entity closest to the origin of the ray, that was hit (if one or more were hit), as well as the point where the ray intersects with the object (or its shield).

function var... invokeFunction(var scriptName, string functionName, var... arguments)

Invokes a function in a script of the sector. Use this function to invoke functions from one script in another script. The first return value of the function is an integer indicating whether or not the call was successful. When it was, this integer is followed by the return values of the invoked function.

Parameters

scriptName The name or index of the script containing the function
functionName The name of the function that will be executed
arguments An arbitrary list of arguments that will be given to the invoked function

Returns

Returns at least 1 value indicating if the call succeeded:
0 The call was successful. In this case, the return values of the script are returned in addition to the call result, following the call result.
3 The call failed because the given script was not found
4 The call failed because the given function was not found in the script
5 The call failed because the script's state has errors and is invalid

function int registerCallback(string callbackName, string functionName)

Register a callback in the sector. The callback receiver has to be inside the sector for the registration to succeed. The callback will be removed if the receiver leaves the sector or gets destroyed, or when a hyperspace jump happens. Double registration of callbacks doesn't work. When the same callback to the same callback of the same script instance is registered twice, it will still only be called once.

Parameters

callbackName The name of the callback
functionName The name of the function that will be executed in the script when the callback happens

Returns

0 on success, 1 if the registration failed

function var removeGlowObject(GlowFX object)

Returns

nothing

function var removeInertiaFieldGlow(var id)

Returns

nothing

function var removeLaser(LaserFX laser)

Returns

nothing

function var removeRefractionObject(RefractionFX object)

Returns

nothing

function var removeStaticHyperspaceGlow(var id)

Returns

nothing

function var resetFog()

Returns

nothing

function var sendCallback()

Returns

nothing

function var setFogColor(Color color)

Returns

nothing

function var setFogColorFactor(float in)

Returns

nothing

function var setFogDensity(float in)

Returns

nothing

function var unregisterCallback(string callbackName, string functionName)

Returns

nothing

Overview
Home Functions Search
Search:

This is the official documentation for the scripting API of Avorion. This documentation is automatically generated and not necessarily complete. Depending on the context in which functions exist, some documentation such as descriptions, return values or variable names or types may be missing.

Work in Progress. Documentation of Avorion Version: 2.5.7 c8e4beec84f7